package com.rs.service.impl.rs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rs.dao.ResignMapper;
import com.rs.model.User;
import com.rs.model.Resign;
import com.rs.service.rs.ResignService;

@Service
public class ResignServiceImpl implements ResignService{

	@Autowired
	private ResignMapper rm;
	//添加离职申请
	@Override
	public Integer resignAddPC(Resign resign) {
		resign.setRg_audit(0);
		return rm.resignAddPC(resign);
	}
	//修改离职申请
	@Override
	public Integer resignUpdatePC(Resign resign) {
		resign.setRg_audit(0);
		return rm.resignUpdatePC(resign);
	}
	//删除离职申请
	@Override
	public Integer resignDelPC(Resign resign) {
		return rm.resignDelPC(resign);
	}
	//查询所有申请
	@Override
	public List<Resign> resignAllPC() {
		return rm.resignAllPC();
	}
	//根据Id查询
	@Override
	public Resign resignByIdPC(Resign resign) {
		return rm.resignByIdPC(resign);
	}
	
	//App查询所有
	@Override
	public List<Resign> resignAllApp() {
		return rm.resignAllApp();
	}
	//App添加申请
	@Override
	public Integer resignAddApp(Resign resign) {
		resign.setRg_audit(0);
		return rm.resignAddApp(resign);
	}
	//App修改申请
	@Override
	public Integer resignUpdateApp(Resign resign) {
		resign.setRg_audit(0);
		return rm.resignUpdateApp(resign);
	}
	//App删除申请
	@Override
	public Integer resignDelApp(Resign resign) {
		return rm.resignDelApp(resign);
	}
	
	
	@Override
	public void resignToExamine(Resign resign) {
		// TODO Auto-generated method stub
		User uu = new User();
		if(resign.getRg_audit()==2) {
			rm.resignUpdatePC(resign);
			return;
		}else if (resign.getRg_audit()==1) {
			rm.resignUpdatePC(resign);
			uu.setU_id(resign.getRg_uid());
			uu.setU_quitTime(resign.getRg_time());
			uu.setU_type(2);
		}
	}
}
